<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      td {
        border: 1px solid red;
        margin: 20px;
      }
      table {
        width: 100px;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <table id="table">
      <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4</td>
        <td>5</td>
        <td>6</td>
      </tr>
      <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4</td>
        <td>5</td>
        <td>6</td>
      </tr>
    </table>
    <script>
      const table = document.querySelector('#table');
      table.addEventListener('click', function (event) {
        if (event.target.tagName.toLowerCase() == 'td') {
          event.target.style.backgroundColor = 'yellow';
        }
      });
    </script>
  </body>
</html>
